Skip to content

Allow customizing visibility of the models generated from third-party protos #1778

@iRevive

Description

@iRevive

The problem

otel4s provides a pure Scala implementation of the OpenTelemetry specification. The protocol models used by otel4s are generated from the third-party protos defined in opentelemetry-proto.

Currently, these models are generated in a public package, making them accessible on the classpath.

This poses a significant problem because opentelemetry-proto may introduce binary-breaking changes. As a result, any updates to the opentelemetry-proto can cause otel4s-sdk-exporter-proto to break binary compatibility.

https://scalapb.github.io/docs/faq/#how-do-i-mark-a-generated-case-class-private doesn't work because proto models are third-party.

The proposition

Perhaps we can extend the package-scoped options to allow customizing modifiers of a package?

import "scalapb/scalapb.proto";

package com.mypackage;

option (scalapb.options) = {
  scope: PACKAGE
  package_modifier: "private[com.mypackage]" // or "private"
};

The workaround

As a workaround, I customized the PB.generate task to override package and visibility afterward: typelevel/otel4s#860.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions