Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions collector/internal/telemetryapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,29 @@ const (
PlatformInitStart EventType = Platform + ".initStart"
// PlatformInitRuntimeDone is used when function initialization ended.
PlatformInitRuntimeDone EventType = Platform + ".initRuntimeDone"
// PlatformReport is used when a report of function invocation is received.
PlatformReport EventType = Platform + ".report"
// Function invocation started.
// PlatformInitReport is used when a report of function initialization is received.
PlatformInitReport EventType = Platform + ".initReport"
// PlatformStart is used when function invocation started.
PlatformStart EventType = Platform + ".start"
// The runtime finished processing an event with either success or failure.
// PlatformRuntimeDone is used when the runtime finished processing an event with either success or failure.
PlatformRuntimeDone EventType = Platform + ".runtimeDone"
// PlatformReport is used when a report of function invocation is received.
PlatformReport EventType = Platform + ".report"
// PlatformRestoreStart is used when runtime restore started.
PlatformRestoreStart EventType = Platform + ".restoreStart"
// PlatformRestoreRuntimeDone is used when runtime restore completed.
PlatformRestoreRuntimeDone EventType = Platform + ".restoreRuntimeDone"
// PlatformRestoreReport is used when a report of runtime restore is received.
PlatformRestoreReport EventType = Platform + ".restoreReport"
// PlatformExtension is used for extension state events.
PlatformExtension EventType = Platform + ".extension"
// PlatformTelemetrySubscription is used when the extension subscribed to the Telemetry API.
PlatformTelemetrySubscription EventType = Platform + ".telemetrySubscription"
// PlatformLogsDropped is used when Lambda dropped log entries.
PlatformLogsDropped EventType = Platform + ".logsDropped"
// Function is used to receive log events emitted by the function
Function EventType = "function"
// Extension is used is to receive log events emitted by the extension
// Extension is used to receive log events emitted by the extension
Extension EventType = "extension"
)

Expand Down
16 changes: 12 additions & 4 deletions collector/receiver/telemetryapireceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ package telemetryapireceiver // import "github.com/open-telemetry/opentelemetry-

import (
"fmt"
"strings"
)

// Config defines the configuration for the various elements of the receiver agent.
type Config struct {
extensionID string
Port int `mapstructure:"port"`
Types []string `mapstructure:"types"`
LogReport bool `mapstructure:"log_report"`
extensionID string
Port int `mapstructure:"port"`
Types []string `mapstructure:"types"`
LogReport bool `mapstructure:"log_report"`
MetricsTemporality string `mapstructure:"metrics_temporality"`
}

// Validate validates the configuration by checking for missing or invalid fields
Expand All @@ -33,5 +35,11 @@ func (cfg *Config) Validate() error {
return fmt.Errorf("unknown extension type: %s", t)
}
}
if cfg.MetricsTemporality != "" {
temporality := strings.ToLower(cfg.MetricsTemporality)
if temporality != "delta" && temporality != "cumulative" {
return fmt.Errorf("unknown metrics temporality: %s", cfg.MetricsTemporality)
}
}
return nil
}
14 changes: 14 additions & 0 deletions collector/receiver/telemetryapireceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func NewFactory(extensionID string) receiver.Factory {
}
},
receiver.WithTraces(createTracesReceiver, stability),
receiver.WithMetrics(createMetricsReceiver, stability),
receiver.WithLogs(createLogsReceiver, stability))
}

Expand All @@ -66,6 +67,19 @@ func createTracesReceiver(ctx context.Context, params receiver.Settings, rConf c
return r, nil
}

func createMetricsReceiver(ctx context.Context, params receiver.Settings, rConf component.Config, next consumer.Metrics) (receiver.Metrics, error) {
cfg, ok := rConf.(*Config)
if !ok {
return nil, errConfigNotTelemetryAPI
}
r := receivers.GetOrAdd(cfg, func() component.Component {
t, _ := newTelemetryAPIReceiver(cfg, params)
return t
})
r.Unwrap().(*telemetryAPIReceiver).registerMetricsConsumer(next)
return r, nil
}

func createLogsReceiver(ctx context.Context, params receiver.Settings, rConf component.Config, next consumer.Logs) (receiver.Logs, error) {
cfg, ok := rConf.(*Config)
if !ok {
Expand Down
Loading
Loading