enhance: Support otlp with insecure (#29115)

issue: https://github.com/milvus-io/milvus/issues/28914

Signed-off-by: Enwei Jiao <enwei.jiao@zilliz.com>
This commit is contained in:
Enwei Jiao 2023-12-12 11:14:37 +08:00 committed by GitHub
parent 0a87724f18
commit 0e65e90338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 7 deletions

View File

@ -703,12 +703,15 @@ quotaAndLimits:
trace:
# trace exporter type, default is stdout,
# optional values: ['stdout', 'jaeger']
# optional values: ['stdout', 'jaeger', 'otlp']
exporter: stdout
# fraction of traceID based sampler,
# optional values: [0, 1]
# Fractions >= 1 will always sample. Fractions < 0 are treated as zero.
sampleFraction: 0
otlp:
endpoint: # "127.0.0.1:4318"
secure: true
jaeger:
url: # "http://127.0.0.1:14268/api/traces"
# when exporter is jaeger should set the jaeger's URL

View File

@ -54,6 +54,7 @@ initTelementry(TraceConfig* config) {
} else if (config->exporter == "otlp") {
auto opts = otlp::OtlpGrpcExporterOptions{};
opts.endpoint = config->otlpEndpoint;
opts.use_ssl_credentials = config->oltpSecure;
exporter = otlp::OtlpGrpcExporterFactory::Create(opts);
LOG_SEGCORE_INFO_ << "init otlp exporter, endpoint:" << opts.endpoint;
} else {

View File

@ -24,6 +24,7 @@ struct TraceConfig {
int sampleFraction;
std::string jaegerURL;
std::string otlpEndpoint;
bool oltpSecure;
int nodeID;
};

View File

@ -76,6 +76,7 @@ InitTrace(CTraceConfig* config) {
config->sampleFraction,
config->jaegerURL,
config->otlpEndpoint,
config->oltpSecure,
config->nodeID};
std::call_once(
traceFlag,

View File

@ -95,6 +95,7 @@ typedef struct CTraceConfig {
int sampleFraction;
const char* jaegerURL;
const char* otlpEndpoint;
bool oltpSecure;
int nodeID;
} CTraceConfig;

View File

@ -45,7 +45,14 @@ func Init() {
exp, err = jaeger.New(jaeger.WithCollectorEndpoint(
jaeger.WithEndpoint(params.TraceCfg.JaegerURL.GetValue())))
case "otlp":
exp, err = otlptracegrpc.New(context.Background(), otlptracegrpc.WithEndpoint(params.TraceCfg.OtlpEndpoint.GetValue()))
secure := params.TraceCfg.OtlpSecure.GetAsBool()
opts := []otlptracegrpc.Option{
otlptracegrpc.WithEndpoint(params.TraceCfg.OtlpEndpoint.GetValue()),
}
if !secure {
opts = append(opts, otlptracegrpc.WithInsecure())
}
exp, err = otlptracegrpc.New(context.Background(), opts...)
case "stdout":
exp, err = stdout.New()
default:

View File

@ -671,6 +671,7 @@ type traceConfig struct {
SampleFraction ParamItem `refreshable:"false"`
JaegerURL ParamItem `refreshable:"false"`
OtlpEndpoint ParamItem `refreshable:"false"`
OtlpSecure ParamItem `refreshable:"false"`
}
func (t *traceConfig) init(base *BaseTable) {
@ -705,8 +706,16 @@ Fractions >= 1 will always sample. Fractions < 0 are treated as zero.`,
t.OtlpEndpoint = ParamItem{
Key: "trace.otlp.endpoint",
Version: "2.3.0",
Doc: "example: \"127.0.0.1:4318\"",
}
t.OtlpEndpoint.Init(base.mgr)
t.OtlpSecure = ParamItem{
Key: "trace.otlp.secure",
Version: "2.4.0",
DefaultValue: "true",
}
t.OtlpSecure.Init(base.mgr)
}
type logConfig struct {