Skip to content

Commit 31f06ae

Browse files
authored
Merge branch 'main' into ta/O11Y-339/basic-android-obs-client-squash
2 parents 83ea410 + 2954803 commit 31f06ae

File tree

9 files changed

+309
-0
lines changed

9 files changed

+309
-0
lines changed

.github/workflows/go-plugin.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Go Observability Plugin
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
pull_request:
7+
types: [opened, synchronize]
8+
paths:
9+
- 'go/**'
10+
- '.github/workflows/go-plugin.yml'
11+
# - 'e2e/tests/**'
12+
13+
concurrency: ${{ github.workflow }}-${{ github.ref }}
14+
jobs:
15+
build:
16+
permissions:
17+
contents: read
18+
name: Quality Check and Publish
19+
runs-on: ubuntu-latest
20+
defaults:
21+
run:
22+
working-directory: ./go
23+
steps:
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
29+
with:
30+
go-version-file: './go/go.mod'
31+
cache-dependency-path: './go/go.sum'
32+
33+
- name: Install dependencies
34+
run: make install
35+
36+
- name: Format check
37+
run: make format
38+
39+
- name: Run linter
40+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9
41+
with:
42+
args: -v --config ./.golangci.yaml
43+
working-directory: go
44+
version: latest
45+
46+
- name: Test
47+
run: make test
48+
49+
- name: Build
50+
run: make build

go/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
coverage.html

go/.golangci.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
version: '2'
2+
run:
3+
tests: false
4+
linters:
5+
enable:
6+
- bodyclose
7+
- dupl
8+
- gochecknoglobals
9+
- gochecknoinits
10+
- goconst
11+
- gocritic
12+
- gocyclo
13+
- godox
14+
- gosec
15+
- lll
16+
- misspell
17+
- nakedret
18+
- nolintlint
19+
- prealloc
20+
- revive
21+
- staticcheck
22+
- unconvert
23+
- unparam
24+
- whitespace
25+
settings:
26+
revive:
27+
rules:
28+
- name: exported
29+
arguments:
30+
- disableStutteringCheck
31+
exclusions:
32+
generated: lax
33+
paths:
34+
- third_party$
35+
- builtin$
36+
- examples$
37+
issues:
38+
max-same-issues: 1000
39+
formatters:
40+
enable:
41+
- gofmt
42+
- goimports
43+
settings:
44+
gofmt:
45+
simplify: false
46+
goimports:
47+
local-prefixes:
48+
- gopkg.in/launchdarkly
49+
- github.com/launchdarkly
50+
exclusions:
51+
generated: lax
52+
paths:
53+
- third_party$
54+
- builtin$
55+
- examples$

go/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
All notable changes to the LaunchDarkly Observability SDK for Go will be documented in this file.

go/Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.PHONY: help install lint test build clean format
2+
3+
# Default target
4+
help:
5+
@echo "Available targets:"
6+
@echo " install - Install dependencies using go mod"
7+
@echo " lint - Run golangci-lint"
8+
@echo " format - Format code using gofmt"
9+
@echo " test - Run tests with coverage"
10+
@echo " build - Build the package"
11+
@echo " clean - Clean build artifacts"
12+
@echo " all - Run install, lint, test, and build"
13+
14+
# Install dependencies
15+
install:
16+
go mod download
17+
go mod tidy
18+
19+
# Run linting with golangci-lint
20+
lint:
21+
golangci-lint run
22+
23+
# Format code with gofmt
24+
format:
25+
gofmt -s -w .
26+
27+
# Run tests with coverage
28+
test:
29+
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
30+
go tool cover -html=coverage.out -o coverage.html
31+
go tool cover -func=coverage.out
32+
33+
# Build the package
34+
build:
35+
go build -v ./...
36+
37+
# Clean build artifacts
38+
clean:
39+
go clean
40+
rm -f coverage.out coverage.html
41+
42+
# Run all checks (install, lint, test, build)
43+
all: install lint test build

go/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
LaunchDarkly Observability SDK for Go
2+
===========================
3+
4+
[![Actions Status][goplugin-sdk-ci-badge]][goplugin-sdk-ci]
5+
6+
7+
# Early Access Preview️
8+
9+
**NB: APIs are subject to change until a 1.x version is released.**
10+
11+
## Install
12+
13+
```shell
14+
go get github.com/launchdarkly/observability-sdk/go
15+
```
16+
17+
Install the plugin when configuring your LaunchDarkly SDK.
18+
19+
```go
20+
// TODO: Add code sample for Go observability plugin configuration
21+
```
22+
23+
LaunchDarkly overview
24+
-------------------------
25+
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!
26+
27+
[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)
28+
29+
## Contributing
30+
31+
We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK.
32+
33+
## About LaunchDarkly
34+
35+
* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
36+
* Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
37+
* Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
38+
* Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
39+
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
40+
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/docs) for a complete list.
41+
* Explore LaunchDarkly
42+
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
43+
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
44+
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
45+
* [launchdarkly.com/blog](https://launchdarkly.com/blog/ "LaunchDarkly Blog Documentation") for the latest product updates
46+
47+
48+
[goplugin-sdk-ci-badge]: https://github.com/launchdarkly/observability-sdk/actions/workflows/go-plugin.yml/badge.svg
49+
[goplugin-sdk-ci]: https://github.com/launchdarkly/observability-sdk/actions/workflows/go-plugin.yml

go/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/launchdarkly/observability-sdk/go
2+
3+
go 1.24.3

go/observability.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Package observability provides LaunchDarkly observability functionality for Go applications.
2+
//
3+
// This package is currently in early access preview. APIs are subject to change
4+
// until a 1.x version is released.
5+
package observability
6+
7+
// observabilityConfig holds configuration for the observability plugin.
8+
type observabilityConfig struct {
9+
serviceName string
10+
serviceVersion string
11+
}
12+
13+
// Option is a function that configures the observability plugin.
14+
type Option func(*observabilityConfig)
15+
16+
// WithServiceName sets the service name for the observability plugin.
17+
func WithServiceName(serviceName string) Option {
18+
return func(c *observabilityConfig) {
19+
c.serviceName = serviceName
20+
}
21+
}
22+
23+
// WithServiceVersion sets the service version for the observability plugin.
24+
func WithServiceVersion(serviceVersion string) Option {
25+
return func(c *observabilityConfig) {
26+
c.serviceVersion = serviceVersion
27+
}
28+
}
29+
30+
// ObservabilityPlugin represents the LaunchDarkly observability plugin.
31+
type ObservabilityPlugin struct {
32+
config observabilityConfig
33+
}
34+
35+
// NewObservabilityPlugin creates a new observability plugin with the given configuration.
36+
func NewObservabilityPlugin(opts ...Option) *ObservabilityPlugin {
37+
config := observabilityConfig{}
38+
for _, opt := range opts {
39+
opt(&config)
40+
}
41+
42+
return &ObservabilityPlugin{
43+
config: config,
44+
}
45+
}

go/observability_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package observability
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestNewObservabilityPlugin(t *testing.T) {
8+
expectedServiceName := "test-service"
9+
expectedServiceVersion := "1.0.0"
10+
11+
plugin := NewObservabilityPlugin(WithServiceName(expectedServiceName), WithServiceVersion(expectedServiceVersion))
12+
13+
if plugin == nil {
14+
t.Fatal("Expected plugin to be created, got nil")
15+
}
16+
17+
if plugin.config.serviceName != expectedServiceName {
18+
t.Errorf("Expected service name %s, got %s", expectedServiceName, plugin.config.serviceName)
19+
}
20+
21+
if plugin.config.serviceVersion != expectedServiceVersion {
22+
t.Errorf("Expected service version %s, got %s", expectedServiceVersion, plugin.config.serviceVersion)
23+
}
24+
}
25+
26+
func TestNewObservabilityPlugin_WithDefaults(t *testing.T) {
27+
plugin := NewObservabilityPlugin()
28+
29+
if plugin == nil {
30+
t.Fatal("Expected plugin to be created, got nil")
31+
}
32+
33+
// Test that default values are empty strings
34+
if plugin.config.serviceName != "" {
35+
t.Errorf("Expected empty service name, got %s", plugin.config.serviceName)
36+
}
37+
38+
if plugin.config.serviceVersion != "" {
39+
t.Errorf("Expected empty service version, got %s", plugin.config.serviceVersion)
40+
}
41+
}
42+
43+
func TestNewObservabilityPlugin_WithPartialOptions(t *testing.T) {
44+
expectedServiceName := "partial-service"
45+
46+
plugin := NewObservabilityPlugin(WithServiceName(expectedServiceName))
47+
48+
if plugin == nil {
49+
t.Fatal("Expected plugin to be created, got nil")
50+
}
51+
52+
if plugin.config.serviceName != expectedServiceName {
53+
t.Errorf("Expected service name %s, got %s", expectedServiceName, plugin.config.serviceName)
54+
}
55+
56+
// Service version should be empty when not provided
57+
if plugin.config.serviceVersion != "" {
58+
t.Errorf("Expected empty service version, got %s", plugin.config.serviceVersion)
59+
}
60+
}

0 commit comments

Comments
 (0)