Skip to content

Commit

Permalink
Add trace to all methods
Browse files Browse the repository at this point in the history
  • Loading branch information
saba committed Apr 2, 2024
1 parent cc51fb5 commit ebf2745
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package api
import (
"context"
"encoding/json"

sdkPlugin "github.com/gatewayd-io/gatewayd-plugin-sdk/plugin"
v1 "github.com/gatewayd-io/gatewayd/api/v1"
"github.com/gatewayd-io/gatewayd/config"
Expand Down Expand Up @@ -102,7 +101,9 @@ func (a *API) GetGlobalConfig(ctx context.Context, group *v1.Group) (*structpb.S
}

// GetPluginConfig returns the plugin configuration of the GatewayD.
func (a *API) GetPluginConfig(context.Context, *emptypb.Empty) (*structpb.Struct, error) {
func (a *API) GetPluginConfig(ctx context.Context, empty *emptypb.Empty) (*structpb.Struct, error) {
_, span := otel.Tracer(config.TracerName).Start(ctx, "Get Plugin Config")
defer span.End()
jsonData, err := json.Marshal(a.Config.Plugin)
if err != nil {
metrics.APIRequestsErrors.WithLabelValues(
Expand Down Expand Up @@ -134,7 +135,9 @@ func (a *API) GetPluginConfig(context.Context, *emptypb.Empty) (*structpb.Struct
}

// GetPlugins returns the active plugin configuration of the GatewayD.
func (a *API) GetPlugins(context.Context, *emptypb.Empty) (*v1.PluginConfigs, error) {
func (a *API) GetPlugins(ctx context.Context, empty *emptypb.Empty) (*v1.PluginConfigs, error) {
_, span := otel.Tracer(config.TracerName).Start(ctx, "Get Plugins")
defer span.End()
plugins := make([]*v1.PluginConfig, 0)
a.PluginRegistry.ForEach(
func(pluginID sdkPlugin.Identifier, plugIn *plugin.Plugin) {
Expand Down Expand Up @@ -177,7 +180,9 @@ func (a *API) GetPlugins(context.Context, *emptypb.Empty) (*v1.PluginConfigs, er
}

// GetPools returns the pool configuration of the GatewayD.
func (a *API) GetPools(context.Context, *emptypb.Empty) (*structpb.Struct, error) {
func (a *API) GetPools(ctx context.Context, empty *emptypb.Empty) (*structpb.Struct, error) {
_, span := otel.Tracer(config.TracerName).Start(ctx, "Get Pools")
defer span.End()
pools := make(map[string]interface{}, 0)
for name, p := range a.Pools {
pools[name] = map[string]interface{}{
Expand All @@ -199,7 +204,9 @@ func (a *API) GetPools(context.Context, *emptypb.Empty) (*structpb.Struct, error
}

// GetProxies returns the proxy configuration of the GatewayD.
func (a *API) GetProxies(context.Context, *emptypb.Empty) (*structpb.Struct, error) {
func (a *API) GetProxies(ctx context.Context, empty *emptypb.Empty) (*structpb.Struct, error) {
_, span := otel.Tracer(config.TracerName).Start(ctx, "Get Proxies")
defer span.End()
proxies := make(map[string]interface{}, 0)
for name, proxy := range a.Proxies {
available := make([]interface{}, 0)
Expand Down Expand Up @@ -232,7 +239,9 @@ func (a *API) GetProxies(context.Context, *emptypb.Empty) (*structpb.Struct, err
}

// GetServers returns the server configuration of the GatewayD.
func (a *API) GetServers(context.Context, *emptypb.Empty) (*structpb.Struct, error) {
func (a *API) GetServers(ctx context.Context, empty *emptypb.Empty) (*structpb.Struct, error) {
_, span := otel.Tracer(config.TracerName).Start(ctx, "Get Servers")
defer span.End()
servers := make(map[string]interface{}, 0)
for name, server := range a.Servers {
servers[name] = map[string]interface{}{
Expand Down

0 comments on commit ebf2745

Please sign in to comment.