enhance: Support otlp with insecure (#29115)

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

Signed-off-by: Enwei Jiao <enwei.jiao@zilliz.com>
pull/29046/head
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

@ -203,15 +203,15 @@ proxy:
accessLog:
enable: true
# Log filename, set as "" to use stdout.
filename: ""
filename: ""
# define formatters for access log by XXX:{format: XXX, method:[XXX,XXX]}
formatters:
# "base" formatter could not set methods
# all method will use "base" formatter default
base:
base:
# will not print access log if set as ""
format: "[$time_now] [ACCESS] <$user_name: $user_addr> $method_name [status: $method_status] [code: $error_code] [msg: $error_msg] [traceID: $trace_id] [timeCost: $time_cost]"
query:
query:
format: "[$time_now] [ACCESS] <$user_name: $user_addr> $method_name [status: $method_status] [code: $error_code] [msg: $error_msg] [traceID: $trace_id] [timeCost: $time_cost] [database: $database_name] [collection: $collection_name] [partitions: $partition_name] [expr: $method_expr]"
# set formatter owners by method name(method was all milvus external interface)
# all method will use base formatter default
@ -223,7 +223,7 @@ proxy:
# rotatedTime: 0 # max time range of singal log file, mean close when time <= 0;
# maxBackups: 8 # num of reserved backups. will rotate and crate a new backup when access log file trigger maxSize or rotatedTime.
# cacheSize: 10240 # write cache of accesslog in Byte
# minioEnable: false # update backups to milvus minio when minioEnable is true.
# remotePath: "access_log/" # file path when update backups to minio
# remoteMaxTime: 0 # max time range(in Hour) of backups in minio, 0 means close time retention.
@ -292,7 +292,7 @@ queryNode:
enableIndex: true
nlist: 128 # segment index nlist
nprobe: 16 # nprobe to search segment, based on your accuracy requirement, must smaller than nlist
memExpansionRate: 1.15 # the ratio of building interim index memory usage to raw data
memExpansionRate: 1.15 # the ratio of building interim index memory usage to raw data
loadMemoryUsageFactor: 1 # The multiply factor of calculating the memory usage while loading segments
enableDisk: false # enable querynode load disk index, and search on disk index
maxDiskUsagePercentage: 95
@ -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 {