Skip to content
Draft
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
1 change: 1 addition & 0 deletions cmd/oss-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func initTracer(ctx context.Context, res *sdkresource.Resource) (*sdktrace.Trace
return tp, nil
}


func main() {
isEndpointProvided := os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") != "" ||
os.Getenv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") != ""
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
go.temporal.io/api v1.50.0
go.temporal.io/sdk v1.34.0
google.golang.org/protobuf v1.36.6
gopkg.in/yaml.v2 v2.4.0
)

require (
Expand Down
11 changes: 11 additions & 0 deletions internal/docs/code_change/markdown_handler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "Code Change Metrics"
---
The Code Change engineering metric quantifies the team’s weekly development activity by measuring the total number of lines of code added, modified, or deleted across our repositories.

* **Source**: Computed from commit diffs in our Git version-control system, excluding merge commits and auto-generated files.
* **Aggregation**: Grouped by ISO week (Monday–Sunday).
* **Purpose**:
* Tracks engineering velocity and throughput over time.
* Highlights spikes (e.g., major feature work or refactors) and troughs (e.g., stabilization periods, planning, or holidays).
* Helps correlate process changes (code freezes, new tooling) with fluctuations in developer output.
3 changes: 3 additions & 0 deletions internal/docs/commits/markdown_handler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: "Commits Metrics"
---
3 changes: 3 additions & 0 deletions internal/docs/deploy_freq/markdown_handler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: "Deploy Frequency Metrics"
---
10 changes: 10 additions & 0 deletions internal/docs/embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package docs

import "embed"

//go:embed */*.md
var DocsFS embed.FS

type MarkdownHandlerFrontmatter struct {
Title string `yaml:"title"`
}
3 changes: 3 additions & 0 deletions internal/docs/merge_freq/markdown_handler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: "Merge Frequency Metrics"
---
3 changes: 3 additions & 0 deletions internal/docs/mr_opened/markdown_handler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: "Merge Frequency Metrics"
---
28 changes: 19 additions & 9 deletions internal/oss-api/handler/code_chage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"net/http"

"github.com/dxta-dev/app/internal/data"
"github.com/dxta-dev/app/internal/docs"
"github.com/dxta-dev/app/internal/markdown"
api "github.com/dxta-dev/app/internal/oss-api"
"github.com/dxta-dev/app/internal/util"
Expand Down Expand Up @@ -39,17 +40,19 @@
return
}

meta, body, err := util.ReadMarkdownFromFS[docs.MarkdownHandlerFrontmatter](
docs.DocsFS,
"code_change/markdown_handler.md",
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

m, err := markdown.GetAggregatedValuesMarkdown(
ctx,
"Code Change Metrics",
`The Code Change engineering metric quantifies the team’s weekly development activity by measuring the total number of lines of code added, modified, or deleted across our repositories.

* **Source**: Computed from commit diffs in our Git version-control system, excluding merge commits and auto-generated files.
* **Aggregation**: Grouped by ISO week (Monday–Sunday).
* **Purpose**:
* Tracks engineering velocity and throughput over time.
* Highlights spikes (e.g., major feature work or refactors) and troughs (e.g., stabilization periods, planning, or holidays).
* Helps correlate process changes (code freezes, new tooling) with fluctuations in developer output.`,
meta.Title,
body,
result,
)
if err != nil {
Expand All @@ -65,6 +68,13 @@
}
}

type OSSMetricQueryBuilder[ func(weeks []string, team *int64) data.AggregatedValuesQuery

Check failure on line 71 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / build-oss-api

syntax error: unexpected newline, expected ]

Check failure on line 71 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / test

expected ']', found newline


func OSSMetricHandler[T any]() {

Check failure on line 74 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / build-oss-api

syntax error: unexpected name OSSMetricHandler, expected (

Check failure on line 74 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / test

missing ',' in parameter list

Check failure on line 74 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / test

expected type, found ')'

Check failure on line 74 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / test

missing ',' in parameter list

Check failure on line 74 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / test

expected type, found ']'

Check failure on line 74 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / test

expected ']', found any

Check failure on line 74 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / test

expected '(', found OSSMetricHandler
}

Check failure on line 75 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / test

expected ')', found newline

Check failure on line 75 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / test

missing ',' in parameter list

Check failure on line 75 in internal/oss-api/handler/code_chage.go

View workflow job for this annotation

GitHub Actions / test

expected ')', found '}'


func CodeChangeHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand Down
39 changes: 39 additions & 0 deletions internal/util/markdown_file.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package util

import (
"fmt"
"io/fs"
"strings"

"gopkg.in/yaml.v2"
)

func ReadMarkdownFromFS[T any](fsys fs.FS, path string) (meta T, body string, err error) {
data, err := fs.ReadFile(fsys, path)
if err != nil {
return meta, "", fmt.Errorf("failed to read %q: %w", path, err)
}
fm, b, err := splitFrontMatter(data)
if err != nil {
return meta, "", err
}
if err := yaml.Unmarshal(fm, &meta); err != nil {
return meta, "", fmt.Errorf("parsing frontmatter into %T: %w", meta, err)
}
return meta, string(b), nil
}

func splitFrontMatter(data []byte) (fm []byte, body []byte, err error) {
const delim = "---\n"
text := string(data)
if !strings.HasPrefix(text, delim) {
return nil, data, nil
}
parts := strings.SplitN(text, "\n---\n", 2)
if len(parts) != 2 {
return nil, nil, fmt.Errorf("invalid frontmatter format")
}
fm = []byte(strings.TrimPrefix(parts[0], delim))
body = []byte(parts[1])
return fm, body, nil
}
Loading