go.temporal.io/server/common/wideevents/events.go
53 LOC · 19 covered · 34 uncovered · 5 ranges · 49 concepts · 5 introducers · 17 tests
File neighbourhood
The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.
Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.
package wideevents
import (
"context"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/log/noop"
)
// instrumentationName is the OTEL instrumentation scope for events emitted by this package.
const instrumentationName = "go.temporal.io/server/common/wideevents"
// Payload is the data of one wide event. Each event type implements it by supplying its stable
// event name and contributing its fields as OTEL log attributes.
type Payload interface {
// EventName is the stable name of the event type. It becomes the log record's event name so
// events are easy to trace/grep by type.
EventName() string
// Attributes returns the event's fields as OTEL log key-values.
Attributes() []log.KeyValue
}
// NewLogger returns the OTEL logger used to emit events for serviceName. serviceName is attached
// as an instrumentation-scope attribute (OTEL semconv service.name) so every emitted event carries
// it, replacing per-event common-tag plumbing.
return lp.Logger(
instrumentationName,
log.WithInstrumentationAttributes(attribute.String("service.name", serviceName)),
)
}
// NoopLogger returns a logger that discards all events. Safe default for tests and for
// deployments that have not opted in to a real LoggerProvider.
return noop.NewLoggerProvider().Logger(instrumentationName)
}
// Emit writes p as a single OTEL log record via logger. A nil logger is a safe no-op so call sites
// never need to guard. Batching, export, and serialization are handled by the LoggerProvider that
// produced logger.
if logger == nil {
}
rec.SetSeverity(log.SeverityInfo)
// The event type is the record's event name so events are easy to trace/grep by type.
rec.SetEventName(p.EventName())
rec.AddAttributes(p.Attributes()...)
logger.Emit(context.Background(), rec)
}