-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.go
More file actions
125 lines (117 loc) · 4.17 KB
/
plugin.go
File metadata and controls
125 lines (117 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Package observability provides an EnginePlugin that contributes all
// observability-related module types: metrics collector, health checker,
// log collector, OpenTelemetry tracing, OpenAPI generator/consumer,
// and distributed trace propagation.
package observability
import (
"github.com/GoCodeAlone/modular"
"github.com/GoCodeAlone/workflow/capability"
"github.com/GoCodeAlone/workflow/module"
"github.com/GoCodeAlone/workflow/plugin"
"github.com/GoCodeAlone/workflow/schema"
)
// ObservabilityPlugin provides metrics, health checking, log collection,
// distributed tracing (OpenTelemetry), and OpenAPI spec generation/consumption.
type ObservabilityPlugin struct {
plugin.BaseEnginePlugin
}
// New creates a new ObservabilityPlugin.
func New() *ObservabilityPlugin {
p := &ObservabilityPlugin{}
p.BaseEnginePlugin = plugin.BaseEnginePlugin{
BaseNativePlugin: plugin.BaseNativePlugin{
PluginName: "observability",
PluginVersion: "1.0.0",
PluginDescription: "Metrics, health checks, log collection, OpenTelemetry tracing, and OpenAPI spec generation/consumption",
},
Manifest: plugin.PluginManifest{
Name: "observability",
Version: "1.0.0",
Author: "GoCodeAlone",
Description: "Metrics, health checks, log collection, OpenTelemetry tracing, and OpenAPI spec generation/consumption",
Tier: plugin.TierCore,
ModuleTypes: []string{
"metrics.collector",
"health.checker",
"log.collector",
"observability.otel",
"openapi.generator",
"http.middleware.otel",
"tracing.propagation",
},
StepTypes: []string{
"step.trace_start",
"step.trace_inject",
"step.trace_extract",
"step.trace_annotate",
"step.trace_link",
},
WiringHooks: []string{
"observability.otel-middleware",
"observability.health-endpoints",
"observability.metrics-endpoint",
"observability.log-endpoint",
"observability.openapi-endpoints",
},
},
}
return p
}
// Capabilities returns the capability contracts this plugin defines.
func (p *ObservabilityPlugin) Capabilities() []capability.Contract {
return []capability.Contract{
{
Name: "metrics",
Description: "Application metrics collection and exposition (Prometheus)",
},
{
Name: "health-check",
Description: "Health, readiness, and liveness endpoint probes",
},
{
Name: "logging",
Description: "Centralized log collection from modules",
},
{
Name: "tracing",
Description: "Distributed tracing via OpenTelemetry",
},
{
Name: "openapi",
Description: "OpenAPI 3.0 spec generation and external API consumption",
},
}
}
// ModuleFactories returns factories for all observability module types.
func (p *ObservabilityPlugin) ModuleFactories() map[string]plugin.ModuleFactory {
return moduleFactories()
}
// ModuleSchemas returns the UI schema definitions for observability module types.
func (p *ObservabilityPlugin) ModuleSchemas() []*schema.ModuleSchema {
return moduleSchemas()
}
// StepFactories returns the tracing pipeline step factories.
func (p *ObservabilityPlugin) StepFactories() map[string]plugin.StepFactory {
return map[string]plugin.StepFactory{
"step.trace_start": func(name string, cfg map[string]any, app modular.Application) (any, error) {
return module.NewTraceStartStepFactory()(name, cfg, app)
},
"step.trace_inject": func(name string, cfg map[string]any, app modular.Application) (any, error) {
return module.NewTraceInjectStepFactory()(name, cfg, app)
},
"step.trace_extract": func(name string, cfg map[string]any, app modular.Application) (any, error) {
return module.NewTraceExtractStepFactory()(name, cfg, app)
},
"step.trace_annotate": func(name string, cfg map[string]any, app modular.Application) (any, error) {
return module.NewTraceAnnotateStepFactory()(name, cfg, app)
},
"step.trace_link": func(name string, cfg map[string]any, app modular.Application) (any, error) {
return module.NewTraceLinkStepFactory()(name, cfg, app)
},
}
}
// WiringHooks returns post-init wiring functions that connect observability
// modules to the HTTP router.
func (p *ObservabilityPlugin) WiringHooks() []plugin.WiringHook {
return wiringHooks()
}