apmconnector

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

README

APM Connector

The APM Connector receives traces from the language agents and generates telemetry that will light up the New Relic APM UI.

Configuration

This connector can act as a trace receiver and a metric and logs exporter. It is best used together with the apm processor.

Here is an example configuration:

receivers:
  otlp:
    protocols:
      grpc:

processors:
  newrelicapm:
  batch:

exporters:
  otlp:
    endpoint: <endpoint>

connectors:
  newrelicapm:

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [newrelicapm, batch]
      exporters: [newrelicapm, otlp]
    metrics:
      receivers: [newrelicapm]
      processors: [batch]
      exporters: [otlp]
    logs:
      receivers: [newrelicapm]
      processors: [batch]
      exporters: [otlp]

Data

Metrics

Based on the traces, transaction duration, error count and apdex are generated.

Logs

Server spans generate Logs which are converted to Transaction events in the New Relic backend.

Spans

For database spans, the db.sql.table is added when it can be extracted from the db.statement attribute.

Documentation

Index

Constants

View Source
const (
	Type                     = "newrelicapm"
	TracesToMetricsStability = component.StabilityLevelDevelopment
	TracesToLogsStability    = component.StabilityLevelDevelopment
)

FIXME copying this from the metadata/generated_status to be able to build the component externally

View Source
const (
	DbOperationAttributeName = "db.operation"
	DbSystemAttributeName    = "db.system"
	DbSQLTableAttributeName  = "db.sql.table"
)

Variables

This section is empty.

Functions

func BuildTransactions

func BuildTransactions(td ptrace.Traces) plog.Logs

func ConvertTraces

func ConvertTraces(logger *zap.Logger, config *Config, td ptrace.Traces) pmetric.Metrics

func DurationInNanos

func DurationInNanos(span ptrace.Span) int64

func GenerateInstanceMetric

func GenerateInstanceMetric(resourceMetrics *ResourceMetrics, hostName string, timestamp pcommon.Timestamp)

Generate the metrc used for the host instances drop down

func GetSdkLanguage

func GetSdkLanguage(attributes pcommon.Map) string

func NanosToSeconds

func NanosToSeconds(nanos int64) float64

func NewFactory

func NewFactory() connector.Factory

NewFactory returns a ConnectorFactory.

func NewSimpleNameProvider

func NewSimpleNameProvider(name string) func(TransactionType) string

Types

type Apdex

type Apdex struct {
	// contains filtered or unexported fields
}

func NewApdex

func NewApdex(apdexT float64) Apdex

func (Apdex) GetApdexBucket

func (apdex Apdex) GetApdexBucket(durationInSeconds float64) string

type ApmLogConnector

type ApmLogConnector struct {
	// contains filtered or unexported fields
}

func (*ApmLogConnector) Capabilities

func (c *ApmLogConnector) Capabilities() consumer.Capabilities

func (*ApmLogConnector) ConsumeTraces

func (c *ApmLogConnector) ConsumeTraces(ctx context.Context, td ptrace.Traces) error

func (*ApmLogConnector) Shutdown

func (c *ApmLogConnector) Shutdown(context.Context) error

func (*ApmLogConnector) Start

type ApmMetricConnector

type ApmMetricConnector struct {
	// contains filtered or unexported fields
}

func (*ApmMetricConnector) Capabilities

func (c *ApmMetricConnector) Capabilities() consumer.Capabilities

func (*ApmMetricConnector) ConsumeTraces

func (c *ApmMetricConnector) ConsumeTraces(ctx context.Context, td ptrace.Traces) error

func (*ApmMetricConnector) Shutdown

func (c *ApmMetricConnector) Shutdown(context.Context) error

func (*ApmMetricConnector) Start

type AttributeFilter

type AttributeFilter struct {
	// contains filtered or unexported fields
}

func NewAttributeFilter

func NewAttributeFilter() *AttributeFilter

func (*AttributeFilter) FilterAttributes

func (attributeFilter *AttributeFilter) FilterAttributes(from pcommon.Map) (pcommon.Map, error)

type Config

type Config struct {
	ApdexT float64 `mapstructure:"apdexT"`
}

type Measurement

type Measurement struct {
	SpanID, MetricName, MetricTimesliceName string
	DurationNanos, ExclusiveDurationNanos   int64
	Attributes                              pcommon.Map
	SegmentNameProvider                     func(TransactionType) string
	// FIXME
	Span ptrace.Span
}

func (Measurement) ExclusiveTime

func (measurement Measurement) ExclusiveTime(transaction *Transaction) int64

type MeterProvider

type MeterProvider struct {
	Metrics pmetric.Metrics
	// contains filtered or unexported fields
}

func NewMeterProvider

func NewMeterProvider() *MeterProvider

type ResourceMetrics

type ResourceMetrics struct {
	// contains filtered or unexported fields
}

func (*ResourceMetrics) GetOrCreateHistogramMetric

func (resourceMetrics *ResourceMetrics) GetOrCreateHistogramMetric(metricName string) pmetric.Histogram

func (*ResourceMetrics) GetOrCreateMetric

func (resourceMetrics *ResourceMetrics) GetOrCreateMetric(metricName string, init func(pmetric.Metric)) pmetric.Metric

func (*ResourceMetrics) GetOrCreateSumMetric

func (resourceMetrics *ResourceMetrics) GetOrCreateSumMetric(metricName string) pmetric.Sum

func (*ResourceMetrics) IncrementSum

func (resourceMetrics *ResourceMetrics) IncrementSum(metricName string, attributes pcommon.Map,
	timestamp pcommon.Timestamp) pmetric.NumberDataPoint

func (ResourceMetrics) RecordHistogram

func (resourceMetrics ResourceMetrics) RecordHistogram(metricName string, attributes pcommon.Map,
	startTimestamp, endTimestamp pcommon.Timestamp, durationNanos int64) pmetric.HistogramDataPoint

func (ResourceMetrics) RecordHistogramFromSpan

func (resourceMetrics ResourceMetrics) RecordHistogramFromSpan(metricName string, attributes pcommon.Map,
	span ptrace.Span) pmetric.HistogramDataPoint

type SQLParser

type SQLParser struct {
}

func NewSQLParser

func NewSQLParser() *SQLParser

func (*SQLParser) ParseDbTableFromSQL

func (sqlParser *SQLParser) ParseDbTableFromSQL(sql string) (string, bool)

func (*SQLParser) ParseDbTableFromSpan

func (sqlParser *SQLParser) ParseDbTableFromSpan(span ptrace.Span) (string, bool)

type Transaction

type Transaction struct {
	SdkLanguage         string
	SpanToChildDuration map[string]int64

	Measurements map[string]*Measurement

	RootSpan ptrace.Span
	// contains filtered or unexported fields
}

func (*Transaction) AddMeasurement

func (transaction *Transaction) AddMeasurement(measurement *Measurement)

func (*Transaction) AddSpan

func (transaction *Transaction) AddSpan(span ptrace.Span)

func (*Transaction) GenerateApdexMetrics

func (transaction *Transaction) GenerateApdexMetrics(span ptrace.Span, err bool, transactionName string, transactionType TransactionType)

func (*Transaction) IncrementErrorCount

func (transaction *Transaction) IncrementErrorCount(transactionName string, transactionType TransactionType, timestamp pcommon.Timestamp)

func (*Transaction) IsRootSet

func (transaction *Transaction) IsRootSet() bool

func (*Transaction) ProcessClientSpan

func (transaction *Transaction) ProcessClientSpan(span ptrace.Span) bool

func (*Transaction) ProcessDatabaseSpan

func (transaction *Transaction) ProcessDatabaseSpan(span ptrace.Span) bool

func (*Transaction) ProcessExternalSpan

func (transaction *Transaction) ProcessExternalSpan(span ptrace.Span) bool

func (*Transaction) ProcessGenericSpan

func (transaction *Transaction) ProcessGenericSpan(span ptrace.Span) bool

func (*Transaction) ProcessMeasurement

func (transaction *Transaction) ProcessMeasurement(measurement *Measurement, transactionType TransactionType, transactionName string)

func (*Transaction) ProcessRootSpan

func (transaction *Transaction) ProcessRootSpan() bool

func (*Transaction) SetRootSpan

func (transaction *Transaction) SetRootSpan(span ptrace.Span)

type TransactionType

type TransactionType string
const (
	WebTransactionType   TransactionType = "Web"
	OtherTransactionType TransactionType = "Other"
	NullTransactionType  TransactionType = "Skip"
)

func GetTransactionMetricName

func GetTransactionMetricName(span ptrace.Span) (string, TransactionType)

func GetWebTransactionMetricName

func GetWebTransactionMetricName(span ptrace.Span, name, nameType string) (string, TransactionType)

func (TransactionType) AsString

func (t TransactionType) AsString() string

func (TransactionType) GetOverviewMetricName

func (t TransactionType) GetOverviewMetricName() string

type TransactionsMap

type TransactionsMap struct {
	Transactions map[string]*Transaction
	// contains filtered or unexported fields
}

func NewTransactionsMap

func NewTransactionsMap(apdexT float64) *TransactionsMap

func (*TransactionsMap) GetOrCreateTransaction

func (transactions *TransactionsMap) GetOrCreateTransaction(sdkLanguage string, span ptrace.Span, resourceMetrics *ResourceMetrics) (*Transaction, string)

func (*TransactionsMap) ProcessTransactions

func (transactions *TransactionsMap) ProcessTransactions()

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL