in connector/elasticapmconnector/config.go [101:306]
func (cfg Config) signaltometricsConfig() *signaltometricsconfig.Config {
// serviceResourceAttributes is the resource attributes included in
// service-level aggregated metrics.
serviceResourceAttributes := []signaltometricsconfig.Attribute{
{Key: "service.name"},
{Key: "deployment.environment"}, // service.environment
{Key: "telemetry.sdk.language"}, // service.language.name
// agent.name is set via elastictraceprocessor for traces,
// but not for other signals. Default to "unknown" for the
// others.
{
Key: "agent.name",
DefaultValue: "unknown",
},
}
// transactionResourceAttributes is the resource attributes included
// in transaction group-level aggregated metrics.
transactionResourceAttributes := append([]signaltometricsconfig.Attribute{
{Key: "container.id"},
{Key: "k8s.pod.name"},
{Key: "service.version"},
{Key: "service.instance.id"}, // service.node.name
{Key: "process.runtime.name"}, // service.runtime.name
{Key: "process.runtime.version"}, // service.runtime.version
{Key: "telemetry.sdk.version"}, // service.language.version??
{Key: "host.name"},
{Key: "os.type"}, // host.os.platform
{Key: "faas.instance"},
{Key: "faas.name"},
{Key: "faas.version"},
{Key: "cloud.provider"},
{Key: "cloud.region"},
{Key: "cloud.availability_zone"},
{Key: "cloud.platform"}, // cloud.service.name
{Key: "cloud.account.id"},
}, serviceResourceAttributes...)
serviceSummaryAttributes := []signaltometricsconfig.Attribute{{
Key: "metricset.name",
DefaultValue: "service_summary",
}}
serviceTransactionAttributes := []signaltometricsconfig.Attribute{
{Key: "transaction.root"},
{Key: "transaction.type"},
{Key: "metricset.name", DefaultValue: "service_transaction"},
}
transactionAttributes := []signaltometricsconfig.Attribute{
{Key: "transaction.root"},
{Key: "transaction.name"},
{Key: "transaction.type"},
{Key: "transaction.result"},
{Key: "event.outcome"},
{Key: "metricset.name", DefaultValue: "transaction"},
}
serviceDestinationAttributes := []signaltometricsconfig.Attribute{
{Key: "span.name"},
{Key: "event.outcome"},
{Key: "service.target.type"},
{Key: "service.target.name"},
{Key: "span.destination.service.resource"},
{Key: "metricset.name", DefaultValue: "service_destination"},
}
// TODO switch to exponential histogram once we have optimised
// exponential histogram merging.
transactionDurationHistogram := &signaltometricsconfig.Histogram{
Buckets: []float64{
5000, 10000, 25000, 50000, 75000, 100000, 250000, 500000,
750000, 1000000, 2500000, 5000000, 7500000, 10000000,
},
Count: "Int(AdjustedCount())",
Value: "Microseconds(end_time - start_time)",
}
transactionDurationSummaryHistogram := &signaltometricsconfig.Histogram{
Buckets: []float64{1},
Count: "Int(AdjustedCount())",
Value: "Microseconds(end_time - start_time)",
}
return &signaltometricsconfig.Config{
Logs: []signaltometricsconfig.MetricInfo{{
Name: "service_summary",
IncludeResourceAttributes: serviceResourceAttributes,
Attributes: serviceSummaryAttributes,
Sum: &signaltometricsconfig.Sum{Value: "1"},
}},
Datapoints: []signaltometricsconfig.MetricInfo{{
Name: "service_summary",
IncludeResourceAttributes: serviceResourceAttributes,
Attributes: serviceSummaryAttributes,
Sum: &signaltometricsconfig.Sum{Value: "1"},
}},
Spans: []signaltometricsconfig.MetricInfo{{
Name: "service_summary",
IncludeResourceAttributes: serviceResourceAttributes,
Attributes: serviceSummaryAttributes,
Sum: &signaltometricsconfig.Sum{
Value: "Int(AdjustedCount())",
},
}, {
Name: "transaction.duration.histogram",
Description: "APM service transaction aggregated metrics as histogram",
IncludeResourceAttributes: serviceResourceAttributes,
Attributes: append(serviceTransactionAttributes[:], signaltometricsconfig.Attribute{
Key: "elasticsearch.mapping.hints",
DefaultValue: []any{"_doc_count"},
}),
Unit: "us",
Histogram: transactionDurationHistogram,
}, {
Name: "transaction.duration.summary",
Description: "APM service transaction aggregated metrics as summary",
IncludeResourceAttributes: serviceResourceAttributes,
Attributes: append(serviceTransactionAttributes[:], signaltometricsconfig.Attribute{
Key: "elasticsearch.mapping.hints",
DefaultValue: []any{"aggregate_metric_double"},
}),
Unit: "us",
Histogram: transactionDurationSummaryHistogram,
}, {
Name: "transaction.duration.histogram",
Description: "APM transaction aggregated metrics as histogram",
IncludeResourceAttributes: transactionResourceAttributes,
Attributes: append(transactionAttributes[:], signaltometricsconfig.Attribute{
Key: "elasticsearch.mapping.hints",
DefaultValue: []any{"_doc_count"},
}),
Unit: "us",
Histogram: transactionDurationHistogram,
}, {
Name: "transaction.duration.summary",
Description: "APM transaction aggregated metrics as summary",
IncludeResourceAttributes: transactionResourceAttributes,
Attributes: append(transactionAttributes[:], signaltometricsconfig.Attribute{
Key: "elasticsearch.mapping.hints",
DefaultValue: []any{"aggregate_metric_double"},
}),
Unit: "us",
Histogram: transactionDurationSummaryHistogram,
}, {
Name: "span.destination.service.response_time.sum.us",
Description: "APM span destination metrics",
IncludeResourceAttributes: serviceResourceAttributes,
Attributes: serviceDestinationAttributes,
Unit: "us",
Sum: &signaltometricsconfig.Sum{
Value: "Double(Microseconds(end_time - start_time))",
},
}, {
Name: "span.destination.service.response_time.count",
Description: "APM span destination metrics",
IncludeResourceAttributes: serviceResourceAttributes,
Attributes: serviceDestinationAttributes,
Sum: &signaltometricsconfig.Sum{
Value: "Int(AdjustedCount())",
},
}, {
// event.success_count is populated using 2 metric definition with different conditions
// and value for the histogram bucket based on event outcome. Both metric definition
// are created using same name and attribute and will result in a single histogram.
// We use mapping hint of aggregate_metric_double, so, only the sum and the count
// values are required and the actual histogram bucket is ignored.
Name: "event.success_count",
Description: "Success count as a metric for service transaction",
IncludeResourceAttributes: serviceResourceAttributes,
Attributes: append(serviceTransactionAttributes[:], signaltometricsconfig.Attribute{
Key: "elasticsearch.mapping.hints",
DefaultValue: []any{"aggregate_metric_double"},
}),
Conditions: []string{
`attributes["event.outcome"] != nil and attributes["event.outcome"] == "success"`,
},
Unit: "us",
Histogram: &signaltometricsconfig.Histogram{
Buckets: []float64{1},
Count: "Int(AdjustedCount())",
Value: "Int(AdjustedCount())",
},
}, {
Name: "event.success_count",
Description: "Success count as a metric for service transaction",
IncludeResourceAttributes: serviceResourceAttributes,
Attributes: append(serviceTransactionAttributes[:], signaltometricsconfig.Attribute{
Key: "elasticsearch.mapping.hints",
DefaultValue: []any{"aggregate_metric_double"},
}),
Conditions: []string{
`attributes["event.outcome"] != nil and attributes["event.outcome"] != "success"`,
},
Unit: "us",
Histogram: &signaltometricsconfig.Histogram{
Buckets: []float64{0},
Count: "Int(AdjustedCount())",
Value: "Double(0)",
},
}},
}
}