Skip to content

Commit

Permalink
Support otlp with insecure
Browse files Browse the repository at this point in the history
Signed-off-by: Enwei Jiao <[email protected]>
  • Loading branch information
jiaoew1991 committed Dec 11, 2023
1 parent 42e538b commit 236dc16
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 7 deletions.
15 changes: 9 additions & 6 deletions configs/milvus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions internal/core/src/common/Tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions internal/core/src/common/Tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct TraceConfig {
int sampleFraction;
std::string jaegerURL;
std::string otlpEndpoint;
bool oltpSecure;

int nodeID;
};
Expand Down
1 change: 1 addition & 0 deletions internal/core/src/common/init_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ InitTrace(CTraceConfig* config) {
config->sampleFraction,
config->jaegerURL,
config->otlpEndpoint,
config->oltpSecure,
config->nodeID};
std::call_once(
traceFlag,
Expand Down
1 change: 1 addition & 0 deletions internal/core/src/common/type_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ typedef struct CTraceConfig {
int sampleFraction;
const char* jaegerURL;
const char* otlpEndpoint;
bool oltpSecure;

int nodeID;
} CTraceConfig;
Expand Down
9 changes: 8 additions & 1 deletion pkg/tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions pkg/util/paramtable/component_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 236dc16

Please sign in to comment.