daml/extractor/BUILD.bazel
Samir Talwar e7e8a5705b
daml-lf/data: Optionally truncate party names in structured logs. [KVL-996] (#10163)
* daml-lf/data: Truncate party names in log output, on request.

The party name can grow quite long, so we offer ledger implementors the
opportunity to truncate it in structured log output.

Unfortunately, because we use Logback through the global
`LoggerFactory`, there is no place to inject logging configuration. This
means we also need to use global, mutable state to configure logging
output. I have added a `LoggingConfiguration` class+object in Daml-LF
Data, which may not be the best place, but I can't think of a better
one right now. I suggest we leave it there until it has reason to grow,
at which point we may want to move it.

CHANGELOG_BEGIN
CHANGELOG_END

* logging-entries: Make `ToLoggingValue` mixin-able.

* participant-integration-api: Truncate parties in filters when logging.

* participant-integration-api: Cast to `Party` for logging.

Invalid input should not break the request at this point. No assertions.

* daml-lf/data: Move `Party to LoggingValue` to a new package.

This avoids the transitive dependency issue most of the time.

* daml-lf-data: Move the `Identifier` logging to another package.

Again, reduces the need for transitively depending on _logging-entries_.
2021-07-01 16:50:49 +00:00

288 lines
9.0 KiB
Python

# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load(
"//bazel_tools:scala.bzl",
"da_scala_binary",
"da_scala_library",
"da_scala_test_suite",
"silencer_plugin",
)
load(
"//rules_daml:daml.bzl",
"daml_compile",
)
load(
"//daml-lf/language:daml-lf.bzl",
"lf_version_configuration",
)
TEST_DARS = [
"RecordsAndVariants",
"PrimitiveTypes",
"TransactionExample",
]
[
daml_compile(
name = darmod,
srcs = ["src/test/resources/damls/%s.daml" % darmod],
target = lf_version_configuration.get("stable"),
)
for darmod in TEST_DARS
]
genrule(
name = "VeryLargeArchive_src",
outs = ["VeryLargeArchive/Blobs.daml"] + ["VeryLargeArchive/Blob%s.daml" % n for n in range(
1,
32 + 1,
)],
cmd =
'''
filecount=32
outs=($(OUTS))
main="$${outs[0]}"
echo '
module VeryLargeArchive.Blobs where
import VeryLargeArchive.Blob1()' > "$$main"
firstfil="$${outs[1]}"
echo '
module VeryLargeArchive.Blob1 where
' > "$$firstfil"
{ for linen in `seq 1 1024`; do
echo -n "x$$linen = "\\"
for charn in `seq 1 16`; do
echo -n qqqqqqqq
done;
echo \\"
done; } >> $$firstfil
for filen in `seq 2 $$filecount`; do
echo "import VeryLargeArchive.Blob$$filen()" >> "$$main"
sed -e '2s/^\\(module .*\\)1/\\1'$$filen/ "$$firstfil" > "$${outs[$$filen]}"
done
''',
)
daml_compile(
name = "VeryLargeArchive",
srcs = [
":VeryLargeArchive/Blobs.daml",
":VeryLargeArchive_src",
],
)
da_scala_library(
name = "extractor",
srcs = glob(["src/main/scala/**/*.scala"]),
plugins = [
silencer_plugin,
],
resources = glob(["src/main/resources/**/*"]),
scala_deps = [
"@maven//:com_chuusai_shapeless",
"@maven//:com_github_scopt_scopt",
"@maven//:com_lihaoyi_fansi",
"@maven//:com_lihaoyi_pprint",
"@maven//:com_lihaoyi_sourcecode",
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
"@maven//:com_typesafe_scala_logging_scala_logging",
"@maven//:io_circe_circe_core",
"@maven//:io_circe_circe_generic",
"@maven//:io_circe_circe_parser",
"@maven//:io_spray_spray_json",
"@maven//:org_scala_lang_modules_scala_collection_compat",
"@maven//:org_scalaz_scalaz_core",
"@maven//:org_tpolecat_doobie_core",
"@maven//:org_tpolecat_doobie_free",
"@maven//:org_typelevel_cats_core",
"@maven//:org_typelevel_cats_effect",
"@maven//:org_typelevel_cats_free",
"@maven//:org_typelevel_cats_kernel",
],
scala_runtime_deps = [
"@maven//:org_tpolecat_doobie_postgres",
],
visibility = ["//visibility:public"],
runtime_deps = [
"@maven//:ch_qos_logback_logback_classic",
"@maven//:ch_qos_logback_logback_core",
],
deps = [
"//daml-lf/data",
"//daml-lf/interface",
"//daml-lf/transaction",
"//language-support/scala/bindings",
"//ledger-api/rs-grpc-akka",
"//ledger-api/rs-grpc-bridge",
"//ledger-service/cli-opts",
"//ledger-service/lf-value-json",
"//ledger-service/utils",
"//ledger/ledger-api-client",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//libs-scala/auth-utils",
"//libs-scala/grpc-utils",
"//libs-scala/ports",
"//libs-scala/timer-utils",
"@maven//:io_netty_netty_handler",
"@maven//:org_slf4j_slf4j_api",
],
)
da_scala_binary(
name = "extractor-binary",
main_class = "com.daml.extractor.Main",
tags = [
"maven_coordinates=com.daml:extractor:__VERSION__",
"no_scala_version_suffix",
],
visibility = ["//visibility:public"],
deps = [
":extractor",
],
)
da_scala_library(
name = "extractor-scala-tests-lib",
srcs = glob(["src/test/lib/**/*.scala"]),
plugins = [
silencer_plugin,
],
scala_deps = [
"@maven//:com_chuusai_shapeless",
"@maven//:com_lihaoyi_sourcecode",
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
"@maven//:com_typesafe_scala_logging_scala_logging",
"@maven//:io_circe_circe_core",
"@maven//:io_circe_circe_parser",
"@maven//:org_scalacheck_scalacheck",
"@maven//:org_scalactic_scalactic",
"@maven//:org_scalatest_scalatest",
"@maven//:org_scalaz_scalaz_core",
"@maven//:org_tpolecat_doobie_core",
"@maven//:org_tpolecat_doobie_free",
"@maven//:org_typelevel_cats_core",
"@maven//:org_typelevel_cats_effect",
"@maven//:org_typelevel_cats_free",
"@maven//:org_typelevel_cats_kernel",
],
scala_runtime_deps = [
"@maven//:org_tpolecat_doobie_postgres",
],
scalacopts = [
"-P:silencer:lineContentFilters=import (services.)?Types._",
],
runtime_deps = [
"@maven//:ch_qos_logback_logback_classic",
"@maven//:io_grpc_grpc_netty",
],
deps = [
":extractor",
"//daml-lf/data",
"//daml-lf/interface",
"//language-support/scala/bindings",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/testing-utils",
"//ledger-service/utils",
"//ledger/ledger-api-client",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/sandbox-classic",
"//ledger/sandbox-classic:sandbox-classic-scala-tests-lib",
"//ledger/sandbox-common",
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
"//libs-scala/auth-utils",
"//libs-scala/ports",
"//libs-scala/postgresql-testing",
"@maven//:io_netty_netty_handler",
"@maven//:org_postgresql_postgresql",
"@maven//:org_slf4j_slf4j_api",
],
)
da_scala_test_suite(
name = "extractor-scala-tests",
size = "medium",
srcs = glob(["src/test/suite/**/*.scala"]),
data = [
"//daml-lf/encoder:testing-dar-latest",
"//extractor:PrimitiveTypes.dar",
"//extractor:RecordsAndVariants.dar",
"//extractor:TransactionExample.dar",
"//extractor:VeryLargeArchive.dar",
"//ledger/test-common:dar-files",
"//ledger/test-common/test-certificates",
],
plugins = [
silencer_plugin,
],
resources = glob(["src/test/resources/**/*"]),
scala_deps = [
"@maven//:com_chuusai_shapeless",
"@maven//:com_github_scopt_scopt",
"@maven//:com_lihaoyi_sourcecode",
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
"@maven//:com_typesafe_scala_logging_scala_logging",
"@maven//:io_circe_circe_core",
"@maven//:io_circe_circe_parser",
"@maven//:org_scalacheck_scalacheck",
"@maven//:org_scalactic_scalactic",
"@maven//:org_scalatest_scalatest",
"@maven//:org_scalatestplus_scalacheck_1_14",
"@maven//:org_scalaz_scalaz_core",
"@maven//:org_scalaz_scalaz_scalacheck_binding",
"@maven//:org_tpolecat_doobie_core",
"@maven//:org_tpolecat_doobie_free",
"@maven//:org_typelevel_cats_core",
"@maven//:org_typelevel_cats_effect",
"@maven//:org_typelevel_cats_free",
"@maven//:org_typelevel_cats_kernel",
],
scalacopts = [
"-P:silencer:lineContentFilters=import (services.)?Types._",
],
deps = [
":extractor",
":extractor-scala-tests-lib",
"//bazel_tools/runfiles:scala_runfiles",
"//daml-lf/data",
"//daml-lf/encoder:testing-dar-lookup-lib-latest",
"//daml-lf/interface",
"//daml-lf/transaction",
"//daml-lf/transaction-test-lib",
"//language-support/scala/bindings",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/testing-utils",
"//ledger-service/utils",
"//ledger/caching",
"//ledger/ledger-api-auth",
"//ledger/ledger-api-client",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/ledger-resources",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/sandbox-classic",
"//ledger/sandbox-classic:sandbox-classic-scala-tests-lib",
"//ledger/sandbox-common",
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
"//ledger/test-common",
"//libs-scala/auth-utils",
"//libs-scala/grpc-utils",
"//libs-scala/ports",
"//libs-scala/postgresql-testing",
"//libs-scala/resources",
"//libs-scala/scalatest-utils",
"//libs-scala/timer-utils",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:io_netty_netty_handler",
"@maven//:org_slf4j_slf4j_api",
],
)
exports_files(["src/main/resources/logback.xml"])