Feat : Update PR as comment

This commit is contained in:
Manendra Pal Singh
2026-02-26 14:45:35 +05:30
parent 18303eb1b5
commit 9d57d3b8f1
31 changed files with 1212 additions and 478 deletions

View File

@@ -41,9 +41,18 @@ func (m metricsProvider) New(ctx context.Context, config map[string]string) (*te
if v := ctx.Value(model.ContextKeyParentID); v != nil {
parentID := v.(string)
p := strings.Split(parentID, ":")
deviceId = p[len(p)-1]
producerType = p[0]
producer = p[1]
if len(p) >= 3 {
producerType = p[0]
producer = p[1]
deviceId = p[len(p)-1]
} else if len(p) >= 2 {
producerType = p[0]
producer = p[1]
deviceId = p[1]
} else if len(p) >= 1 {
producerType = p[0]
deviceId = p[0]
}
}
if deviceId != "" {
@@ -97,7 +106,7 @@ func (m metricsProvider) New(ctx context.Context, config map[string]string) (*te
}
}
//to set network leval matric frequency and granularity
//to set network level matric frequency and granularity
if v, ok := config["networkMetricsGranularity"]; ok && v != "" {
telemetry.SetNetworkMetricsConfig(v, "")
}

View File

@@ -108,7 +108,7 @@ func (Setup) New(ctx context.Context, cfg *Config) (*telemetry.Provider, error)
}, nil
}
//this will be used by both matric and traces
//this will be used by both metric and traces
// to build resource with envelope metadata
baseAttrs := []attribute.KeyValue{
@@ -123,10 +123,10 @@ func (Setup) New(ctx context.Context, cfg *Config) (*telemetry.Provider, error)
resMetric, err := resource.New(ctx, resource.WithAttributes(buildAtts(baseAttrs, "METRIC")...))
if err != nil {
return nil, fmt.Errorf("failed to create telemetry resource for matric: %w", err)
return nil, fmt.Errorf("failed to create telemetry resource for metric: %w", err)
}
//OTLP matric
//OTLP metric
var meterProvider *metric.MeterProvider
if cfg.EnableMetrics {
metricExpoter, err := otlpmetricgrpc.New(ctx, otlpmetricgrpc.WithEndpoint(cfg.OtlpEndpoint),
@@ -139,7 +139,7 @@ func (Setup) New(ctx context.Context, cfg *Config) (*telemetry.Provider, error)
otel.SetMeterProvider(meterProvider)
log.Infof(ctx, "OpenTelemetry metrics initialized for service=%s version=%s env=%s (OTLP endpoint=%s)",
cfg.ServiceName, cfg.ServiceVersion, cfg.Environment, cfg.OtlpEndpoint)
// for the go runtime matrics
// for the go runtime metrics
if err := runtime.Start(runtime.WithMinimumReadMemStatsInterval(runtime.DefaultMinimumReadMemStatsInterval)); err != nil {
log.Warnf(ctx, "Failed to start Go runtime instrumentation: %v", err)
}

View File

@@ -75,8 +75,8 @@ func NewPreProcessor(cfg *Config) (func(http.Handler) http.Handler, error) {
}
if callerID != nil {
log.Debugf(ctx, "adding callerID to request:%s, %v", model.ContextKeyCallerID, callerID)
ctx = context.WithValue(ctx, model.ContextKeyCallerID, callerID)
log.Debugf(ctx, "adding callerID to request:%s, %v", model.ContextKeyRemoteID, callerID)
ctx = context.WithValue(ctx, model.ContextKeyRemoteID, callerID)
}
for _, key := range cfg.ContextKeys {
ctxKey, _ := model.ParseContextKey(key)