|
| 1 | +// Copyright 2019, OpenCensus Authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package zipkinreceiver |
| 16 | + |
| 17 | +import ( |
| 18 | + "context" |
| 19 | + |
| 20 | + "github.com/open-telemetry/opentelemetry-service/consumer" |
| 21 | + "github.com/open-telemetry/opentelemetry-service/internal/configmodels" |
| 22 | + "github.com/open-telemetry/opentelemetry-service/internal/factories" |
| 23 | + "github.com/open-telemetry/opentelemetry-service/receiver" |
| 24 | +) |
| 25 | + |
| 26 | +// This file implements config V2 for Zipkin receiver. |
| 27 | + |
| 28 | +var _ = factories.RegisterReceiverFactory(&ReceiverFactory{}) |
| 29 | + |
| 30 | +const ( |
| 31 | + // The value of "type" key in configuration. |
| 32 | + typeStr = "zipkin" |
| 33 | + |
| 34 | + defaultBindEndpoint = "127.0.0.1:9411" |
| 35 | +) |
| 36 | + |
| 37 | +// ReceiverFactory is the factory for Zipkin receiver. |
| 38 | +type ReceiverFactory struct { |
| 39 | +} |
| 40 | + |
| 41 | +// Type gets the type of the Receiver config created by this factory. |
| 42 | +func (f *ReceiverFactory) Type() string { |
| 43 | + return typeStr |
| 44 | +} |
| 45 | + |
| 46 | +// CustomUnmarshaler returns nil because we don't need custom unmarshaling for this config. |
| 47 | +func (f *ReceiverFactory) CustomUnmarshaler() factories.CustomUnmarshaler { |
| 48 | + return nil |
| 49 | +} |
| 50 | + |
| 51 | +// CreateDefaultConfig creates the default configuration for Jaeger receiver. |
| 52 | +func (f *ReceiverFactory) CreateDefaultConfig() configmodels.Receiver { |
| 53 | + return &ConfigV2{ |
| 54 | + ReceiverSettings: configmodels.ReceiverSettings{ |
| 55 | + TypeVal: typeStr, |
| 56 | + NameVal: typeStr, |
| 57 | + Endpoint: defaultBindEndpoint, |
| 58 | + }, |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +// CreateTraceReceiver creates a trace receiver based on provided config. |
| 63 | +func (f *ReceiverFactory) CreateTraceReceiver( |
| 64 | + ctx context.Context, |
| 65 | + cfg configmodels.Receiver, |
| 66 | + nextConsumer consumer.TraceConsumer, |
| 67 | +) (receiver.TraceReceiver, error) { |
| 68 | + |
| 69 | + rCfg := cfg.(*ConfigV2) |
| 70 | + return New(rCfg.Endpoint, nextConsumer) |
| 71 | +} |
| 72 | + |
| 73 | +// CreateMetricsReceiver creates a metrics receiver based on provided config. |
| 74 | +func (f *ReceiverFactory) CreateMetricsReceiver( |
| 75 | + cfg configmodels.Receiver, |
| 76 | + consumer consumer.MetricsConsumer, |
| 77 | +) (receiver.MetricsReceiver, error) { |
| 78 | + return nil, factories.ErrDataTypeIsNotSupported |
| 79 | +} |
0 commit comments